// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "WeaponBuildingBase.h"
#include "Components/SplineMeshComponent.h"
#include "ElecData.h"
#include "ElecCustomLogicBase.h"
#include "ElecUnitBase.generated.h"

/**
 * 
 */
class UElecCustomLogicBase;

UCLASS()
class ISALONG2_API AElecUnitBase : public AWeaponBuildingBase
{
	GENERATED_BODY()

public:
	AElecUnitBase();

	bool IsProvider();

	bool ConstValue();
	
protected:
	
	USplineMeshComponent* _splMesh;

protected:
	// is whether this unit be a provider or not
	bool _asProvider = false;

	// const value of this source only work when as provider
	bool _constVal = false;

	FElecData* _dataPack;
	
	TArray<AElecUnitBase*> _otherUnits;

	TArray<UElecCustomLogicBase*> _buildingLogics;

	virtual void OnUnitBeginOverlapHelp(AElecUnitBase* otherUnit) {}

	virtual void OnUnitEndOverlapHelp(AElecUnitBase* otherUnit) {}

public:
	virtual void OnFireBegin();

	virtual void OnFireEnd();

	virtual void Tick(float DeltaSeconds) override;

	virtual void SetUpData(FInteractData* data, int itemType) override;

private:

	UFUNCTION()
	void OnUnitBeginOverlap(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

	UFUNCTION()
	void OnUnitEndOverlap(AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex);
};
